package com.business.system.official.toursism.websitehotel.manager.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.business.system.official.toursism.websitehotel.entity.WebsiteHotel;
import com.business.system.official.toursism.websitehotel.manager.WebsiteHotelManager;
import com.business.system.official.toursism.websitehotel.mapper.WebsiteHotelMapper;
import com.business.system.official.toursism.websitehotel.vo.WebsiteHotelBriefListVO;
import com.business.system.official.toursism.websitehotel.vo.WebsiteHotelBriefVO;
import com.business.system.official.toursism.websitehotel.vo.WebsiteHotelDetailListVO;
import com.business.system.official.toursism.websitehotel.vo.WebsiteHotelDetailVO;
import com.business.system.official.toursism.websitehotel.vo.data.WebsiteHotelBriefData;
import com.business.system.official.toursism.websitehotel.vo.data.WebsiteHotelDetailData;
import com.seed.core.exception.ManagerException;
import com.seed.core.pojo.manager.impl.SeedSystemManagerImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 乌镇酒店
 * @author CodeGenerator
 * @date   2025-01-25
 * @version V1.0
 */
@Slf4j
@Transactional(rollbackFor = ManagerException.class)
@Service("websiteHotelManager")
public class WebsiteHotelManagerImpl extends SeedSystemManagerImpl<WebsiteHotelMapper, WebsiteHotel> implements WebsiteHotelManager {

    /**
     * 根据id获取详情VO data
     *
     * @param websiteHotelId 对象id
     * @return 详情VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelDetailData convertDetailData(String websiteHotelId) throws ManagerException {
        WebsiteHotel websiteHotel = this.getById(websiteHotelId);
        return this.convertDetailData(websiteHotel);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteHotel model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelDetailData convertDetailData(WebsiteHotel websiteHotel) throws ManagerException {
        WebsiteHotelDetailData websiteHotelDetailData = new WebsiteHotelDetailData();
        try {
            BeanUtils.copyProperties(websiteHotel, websiteHotelDetailData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteHotel);
        }
        return websiteHotelDetailData;
    }

    /**
     * 根据id获取详情VO
     *
     * @param websiteHotelId 对象id
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelDetailVO getDetailVO(String websiteHotelId) throws ManagerException {
        WebsiteHotelDetailData websiteHotelDetailData = this.convertDetailData(websiteHotelId);
        return new WebsiteHotelDetailVO(websiteHotelDetailData);
    }

    /**
     * 根据对象获取详情VO
     *
     * @param websiteHotel 对象
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelDetailVO getDetailVO(WebsiteHotel websiteHotel) throws ManagerException {
        WebsiteHotelDetailData websiteHotelDetailData = this.convertDetailData(websiteHotel);
        return new WebsiteHotelDetailVO(websiteHotelDetailData);
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelDetailData> getConvertDetailListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteHotel> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteHotel::getId, ids);
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return this.listConvertDetailData(websiteHotelList);
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelDetailData> listConvertDetailData(Wrapper<WebsiteHotel> queryWrapper) throws ManagerException {
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return this.listConvertDetailData(websiteHotelList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteHotelList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelDetailData> listConvertDetailData(List<WebsiteHotel> websiteHotelList) throws ManagerException {
        List<WebsiteHotelDetailData> websiteHotelDetailDataList = new ArrayList<>();
        for (WebsiteHotel websiteHotel : websiteHotelList) {
            websiteHotelDetailDataList.add(this.convertDetailData(websiteHotel));
        }
        return websiteHotelDetailDataList;
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelDetailListVO getDetailListVOByIds(List<String> ids) throws ManagerException {
        return new WebsiteHotelDetailListVO(this.getConvertDetailListVOByIds(ids));
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelDetailListVO getDetailListVO(Wrapper<WebsiteHotel> queryWrapper) throws ManagerException {
        return new WebsiteHotelDetailListVO(this.listConvertDetailData(queryWrapper));
    }

    /**
     * 根据对象list获取详情VO data list
     *
     * @param websiteHotelList 对象list
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelDetailListVO getDetailListVO(List<WebsiteHotel> websiteHotelList) throws ManagerException {
        return new WebsiteHotelDetailListVO(this.listConvertDetailData(websiteHotelList));
    }

    /**
     * 根据id获取简略VO data
     *
     * @param websiteHotelId 对象id
     * @return 简略VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelBriefData convertBriefData(String websiteHotelId) throws ManagerException {
        WebsiteHotel websiteHotel = this.getById(websiteHotelId);
        return this.convertBriefData(websiteHotel);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteHotel model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelBriefData convertBriefData(WebsiteHotel websiteHotel) throws ManagerException {
        WebsiteHotelBriefData websiteHotelBriefData = new WebsiteHotelBriefData();
        try {
            BeanUtils.copyProperties(websiteHotel, websiteHotelBriefData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteHotel);
        }
        return websiteHotelBriefData;
    }

    /**
     * 根据id获取简略VO
     *
     * @param websiteHotelId 对象id
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelBriefVO getBriefVO(String websiteHotelId) throws ManagerException {
        WebsiteHotelBriefData websiteHotelBriefData = this.convertBriefData(websiteHotelId);
        return new WebsiteHotelBriefVO(websiteHotelBriefData);
    }

    /**
     * 根据对象获取简略VO
     *
     * @param websiteHotel 对象
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelBriefVO getBriefVO(WebsiteHotel websiteHotel) throws ManagerException {
        WebsiteHotelBriefData websiteHotelBriefData = this.convertBriefData(websiteHotel);
        return new WebsiteHotelBriefVO(websiteHotelBriefData);
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelBriefData> listConvertBriefDataByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteHotel> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteHotel::getId, ids);
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return this.listConvertBriefData(websiteHotelList);
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelBriefData> listConvertBriefData(Wrapper<WebsiteHotel> queryWrapper) throws ManagerException {
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return this.listConvertBriefData(websiteHotelList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteHotelList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelBriefData> listConvertBriefData(List<WebsiteHotel> websiteHotelList) throws ManagerException {
        List<WebsiteHotelBriefData> websiteHotelBriefDataList = new ArrayList<>();
        for (WebsiteHotel websiteHotel : websiteHotelList) {
            websiteHotelBriefDataList.add(this.convertBriefData(websiteHotel));
        }
        return websiteHotelBriefDataList;
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelBriefListVO getBriefListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteHotel> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteHotel::getId, ids);
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return new WebsiteHotelBriefListVO(this.listConvertBriefData(websiteHotelList));
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelBriefListVO getBriefListVO(Wrapper<WebsiteHotel> queryWrapper) throws ManagerException {
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return new WebsiteHotelBriefListVO(this.listConvertBriefData(websiteHotelList));
    }

    /**
     * 根据对象list获取简略VO data list
     *
     * @param websiteHotelList 对象list
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelBriefListVO getBriefListVO(List<WebsiteHotel> websiteHotelList) throws ManagerException {
        return new WebsiteHotelBriefListVO(this.listConvertBriefData(websiteHotelList));
    }
}
